<template>
	<view class="container">
		<view style="background-color: #fff;">
			<!-- <uni-steps :options="[{title: '鉴定信息'}, {title: '鉴定评级'}, {title: '户主签字'}]" :active="active" /> -->
			<uni-segmented-control :current="active" :values="['鉴定信息','鉴定评级', '户主签字']" style-type="text"
								active-color="#007aff" @clickItem="changeItem" />
		</view>
		<StepFirst ref="firstStep" v-model="formData" v-if="active == 0" :satisfy-status = "satisfyStatusOptions"/>
		<StepSecond ref="secondStep" v-model="formData" v-if="active == 1" />
		<view class="button-group" style="background-color: #fff;">
			<button class="bg-blue" size="mini" style="margin: 30px 10px 50px; width: 200px;" @click="saveIdentify">保 存</button>
		</view>
	</view>
</template>

<script>
	import { getDictDatas } from '@/utils/dict.js'
	import { addHouseIdentify } from '@/api/busin/identify/index.js'
	import StepFirst from './components/stepFirst.vue'
	import StepSecond from './components/stepSecond.vue'
	
	export default {
		components: {
			StepFirst,
			StepSecond
		},
		data() {
			return {
				active: 0,
				formData: {
					projectId: undefined,
					province: '',
					city: '',
					district: '',
					township: '',
					villages: '',
					address: '',
					buildTime: 1970,
					structureType: 1,
					layers: 1,
					layersText: '',
					floorSpace: undefined,
					identifyData: {
						hunningtu: undefined,
						qitizhuan: undefined,
						qizhushajiang: undefined,
						qiangtihoudu: 180,
						zhuankangya: '0',
						qizhushajiangkangya: '0',
						huningtukangya: '0',
						dingdianweiyi: '0',
						liefengbianxing: '0',
						waiguanzhiliangquexian: '0',
						dijiyichang: '0',
						shangbuyichang: '0',
						dijizhuangkuang: '0',
						chengzailiyansuan: '0'
					}
				},
				satisfyStatusOptions: [],
			}
		},
		created() {
			getDictDatas('busin_satisfy_status').forEach((item, index) => {
				this.satisfyStatusOptions.push({
					value: item.value,
					text: item.label
				})
			})
		},
		methods: {
			saveIdentify() {
				uni.showLoading({
					title: '保存中，请稍等...'
				})
				// console.log(this.formData)
				addHouseIdentify(this.formData).then(() => {
					uni.hideLoading()
					this.$modal.msgSuccess("注册成功")
					uni.reLaunch({
						url: '/pages/work/index'
					})
				}).catch((error) => {
					uni.hideLoading()
				})
				uni.hideLoading()
			},
			changeItem(e) {
				if (this.active !== e.currentIndex) {
					this.active = e.currentIndex
				}
				console.log(this.active)
			},
		}
	}
</script>

<style>
.segmented-control {
	margin-bottom: 0px;
}
</style>
